import { assertEquals } from "asserts";

import fractionToDecimal from "./index.ts";

Deno.test("fraction-to-recurring-decimal", () => {
    assertEquals(
        [
            "1.(000050002500125006250312515625781289064453222661133056652832641632081604080204010200510025501275063753187659382969148457422871143557177858892944647232361618080904045202260113005650282514125706285314265713285664283214160708035401770088504425221261063053152657632881644082204110205510275513775688784439221961098054902745137256862843142157107855392769638481924096204810240512025601280064003200160008000400020001)",
            "0.99995",
        ],
        [[20000, 19999], [19999, 20000]].map((a) =>
            fractionToDecimal(a[0], a[1])
        ),
    );
});
Deno.test("fraction-to-recurring-decimal", () => {
    assertEquals(
        [
            "0.5",
            "2",
            "0.(012)",
            "0.(523809)",
            "1.(90)",
            "0.(123)",
            "0.(523809)",
            "1.(90)",
            "2.05",
            "0.(213)",
        ],
        [
            [1, 2],
            [2, 1],
            [4, 333],
            [11, 21],
            [21, 11],
            [41, 333],
            [11, 21],
            [21, 11],
            [41, 20],
            [71, 333],
        ].map((a) => fractionToDecimal(a[0], a[1])),
    );
});
